package com.android.readcard.mvp.imp;

import com.android.readcard.mvp.base.BaseInfo;
import com.android.readcard.mvp.inter.ArticlePresenter;
import com.android.readcard.mvp.inter.MyArticleView;
import com.android.readcard.mvp.listener.MyMvpListener;

public class ArticlePresenterImpl implements ArticlePresenter, MyMvpListener {
    private MyArticleView myArticleView;
    private MyModelImpl myModel;

    // 构造方法里面传入控制视图的监听
    public ArticlePresenterImpl(MyArticleView myArticleView) {
        this.myArticleView = myArticleView;
        myModel = new MyModelImpl();
    }

    @Override
    public void getData() {
        myArticleView.showLoading();
        myModel.getData(this);
    }

    @Override
    public void onSuccess(BaseInfo baseInfo) {
        myArticleView.setArticleInfo(baseInfo);
        myArticleView.hideLoading();
    }

    @Override
    public void onFailed(int errCode, String errMsg) {
        myArticleView.showError(errCode, errMsg);
        myArticleView.hideLoading();
    }
}
